var lastresult = true;
var zjname = "";

$("#outerdiv").hide();
$("#shows").hide();
$("#Material").hide();
function imgShow(outerdiv, bigimg, _this) {
    var src = _this.attr("src");//获取当前点击的pimg元素中的src属性
    $("#outerdiv").attr("display", "block");
    $("#bigimg").attr("src", src);  //设置#bigimg元素的src属性
    $("#outerdiv").fadeIn("fast");

    $("#outerdiv").click(function () {//再次点击淡出消失弹出层
        $(this).fadeOut("fast");
    });
}


var vm = new Vue({
    el : "#cuttingJobs",
    data : {
    },
    init:function(){
        var _self = this;
        layui.use(['layer'], function(){
            layer = layui.layer;
        });


        var str=decodeURI(location.href); //取得整个地址栏
        var num=str.indexOf("?")
        str=str.substr(num+1); //取得所有参数   stringvar.substr(start [, length ]

        var resultsQqy = null;

        var arr=str.split("&"); //各个参数放到数组里
        for(var i=0;i < arr.length;i++){
            num=arr[i].indexOf("=");
            if(num>0){
                resultsQqy = "false";
            }
        }



        if(resultsQqy == null){
            _self.$nextTick(function() {
                _self.$http.post("../../CuttingJobsr/getPhotoLists",{PhotoCode:str},{emulateJSON: true}).then(function(res){
                    if(res.ok){
                        _self.Photolists = res.body.Photolist;
                        if(res.body.Photolist.length == 0){
                            _self.vueAlert("无矢量图信息！");
                            return;
                        }
                        var equipmentwork = "";
                        for( i = 0 ; i<res.body.Photolist.length ; i++){

                            equipmentwork +="<div class='layui-inline' class= 'divcss5'  >  " ;

                            equipmentwork +="<div class='layui-col-xs4' class='div_card'>" ;

                            equipmentwork +="<div class='layui-row' >";
                            equipmentwork +="<div style='width:100px;float:left;' id ='outerdiv'>";
                            equipmentwork +="<img id=\"bigimg\" src='" + host + "file?id="+_self.Photolists[i].EMES_FILE_ID+"'   style=\"margin-top:10px;\" class=\"div_card_image\" name='"+i+"' >";
                            equipmentwork +="</div>";

                            equipmentwork +="<div style=\"float:left;margin-left:10px;\">";
                            equipmentwork +="<div class=\"div_card_name\"> <input disabled=\"\" value='工单:    "+_self.Photolists[i].ZYCODE+"'/></div>";
                            equipmentwork +="<div class=\"div_card_name\"> <input disabled=\"\" value='部位：   "+_self.Photolists[i].BWNAME+"'/></div>";
                            equipmentwork +="<div class=\"div_card_name\"> <input disabled=\"\"  value='颜色：   "+_self.Photolists[i].YSNAME+"'/></div>";
                            equipmentwork +="<div ></div>";
                            equipmentwork +="</div>";
                            equipmentwork +="</div>";


                            equipmentwork +="</div>";

                            equipmentwork +="</div>";

                        }
                        $("#cuttingPhoto").html(equipmentwork);

                        layui.use(['form'], function(){
                            form = layui.form;
                            form.render(); //这个很重要
                        });
                    }

                    $("img").mouseover(function(){
                        $(this).css("cursor","pointer");
                    });

                    $("img").click(function(){
                        var _this = $(this);//将当前的pimg元素作为_this传入函数
                        imgShow("#outerdiv", "#bigimg", _this);
                    });
                    $("#tupiancode").attr("value", str);
                    $("#shows").show();
                });
            });
        }


    },
    methods: {
        getPhotoByCode: function(event){
            var _self = this;

            var PhotoIds = document.getElementById("PhotoId").value;   //矢量图编码ID

            if (event.keyCode != 13 || !(PhotoIds && PhotoIds.length > 0)) {
                return;
            }

            _self.$nextTick(function() {
                _self.$http.post("../../CuttingJobsr/getPhotoLists",{PhotoCode:PhotoIds},{emulateJSON: true}).then(function(res){
                    if(res.ok){
                        _self.Photolists = res.body.Photolist;
                        if(res.body.Photolist.length == 0){
                            _self.vueAlert("无矢量图信息！");
                            return;
                        }
                        var equipmentwork = "";
                        for( i = 0 ; i<res.body.Photolist.length ; i++){

                            equipmentwork +="<div class='layui-inline' class= 'divcss5'  >  " ;

                            equipmentwork +="<div class='layui-col-xs4' class='div_card'>" ;

                            equipmentwork +="<div class='layui-row' >";
                            equipmentwork +="<div style='width:100px;float:left;' id ='outerdiv'>";
                            equipmentwork +="<img id=\"bigimg\" src='" + host + "file?id="+_self.Photolists[i].EMES_FILE_ID+"'   style=\"margin-top:10px;\" class=\"div_card_image\" name='"+i+"' >";
                            equipmentwork +="</div>";

                            equipmentwork +="<div style=\"float:left;margin-left:10px;\">";
                            equipmentwork +="<div class=\"div_card_name\"> <input disabled=\"\" value='工单:    "+_self.Photolists[i].ZYCODE+"'/></div>";
                            equipmentwork +="<div class=\"div_card_name\"> <input disabled=\"\" value='部位：   "+_self.Photolists[i].BWNAME+"'/></div>";
                            equipmentwork +="<div class=\"div_card_name\"> <input disabled=\"\"  value='颜色：   "+_self.Photolists[i].YSNAME+"'/></div>";
                            equipmentwork +="<div ></div>";
                            equipmentwork +="</div>";
                            equipmentwork +="</div>";


                            equipmentwork +="</div>";

                            equipmentwork +="</div>";

                        }
                        $("#cuttingPhoto").html(equipmentwork);

                        layui.use(['form'], function(){
                            form = layui.form;
                            form.render(); //这个很重要
                        });
                    }

                    $("img").mouseover(function(){
                        $(this).css("cursor","pointer");
                    });

                    $("img").click(function(){
                        var _this = $(this);//将当前的pimg元素作为_this传入函数
                        imgShow("#outerdiv", "#bigimg", _this);
                    });
                    $("#tupiancode").attr("value", PhotoIds);
                    $("#shows").show();
                });
            });


        }
        ,reset: function(data){
            window.location.reload();
        }
        ,vueAlert: function(msg){
            layui.use(['form'], function(){
                var layer = layui.layer;
                layer.msg(msg,{icon:6,time:2000});
            });
        }
        ,clearReceiveForm: function(){
            $("#reMakeNum").val('');
            $("#confirmReceiveNum").val('');
        },
        showHistory: function () {
            top.winIndex = top.layer.open({
                type: 2,
                title: "完工查询",
                shadeClose: true,
                shade: 0.6,
                area: ['80%', '80%'],
                fixed:true,
                content: host + 'mes/manu/jobOrderHistory.html',
                end:function(){
                }
            });
        },
        // 异常上报
        abnormalReport: function() {
            layer.open({
                type: 2,
                title: '异常上报',
                shadeClose: true,
                shade: 0.8,
                area: ['90%', '90%'],
                content: "abnormalReport.html" //iframe的url
            });
        }

    }
});
